Correctness
When we have a function, how can we show the function we write is correct?
Formally, we define the input and output, and try to prove input output
That is, after we have the definition of input and out, then we do following to prove a function's correctness:
- define loop invariant
- Initialization
- Maintenance(inductive step)
- Termination
- Descending sequence
Actually, this part is the most tough part of the course where sometimes hard to find a intuitive way to prove correctness.